* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
}

header {
    background-color: #4CAF50;
    color: white;
    padding: 1rem;
}

nav ul {
    display: flex;
    list-style: none;
}

nav ul li {
    margin-right: 1rem;
}

/* 头部容器样式 */
.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 导航链接样式 */
nav ul li a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

nav ul li a:hover, nav ul li a.active {
    background-color: rgba(255, 255, 255, 0.2);
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.hero {
    background-color: #e8f5e9;
    padding: 3rem;
    text-align: center;
    margin-bottom: 2rem;
}

/* 按钮样式 */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s, border-color 0.3s;
}

.btn-primary {
    background-color: #4CAF50;
    color: white;
    border: 1px solid #4CAF50;
}

.btn-primary:hover {
    background-color: #45a049;
    border-color: #45a049;
}

/* 操作按钮容器 */
.action-buttons {
    margin-bottom: 1.5rem;
}

/* 帖子项样式 */
.post-item {
    background-color: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.post-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* 封面图片样式 */
.post-cover-image {
    width: 100%;
    height: auto;
    border-radius: 4px;
    margin-bottom: 1rem;
}

/* 无帖子提示样式 */
.no-posts {
    text-align: center;
    padding: 3rem;
    color: #666;
}

/* 帖子元信息样式 */
.post-meta {
    display: flex;
    gap: 1.5rem;
    color: #666;
    font-size: 0.9rem;
    margin-top: 1rem;
}

/* 修改featured-posts样式，移除flex布局 */
.featured-posts {
    margin-bottom: 2rem;
}

/* 正确定义post-grid为CSS Grid布局 */
.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

/* 优化post-card样式 */
/* 统一所有帖子卡片的样式和高度 */
/* 修复帖子卡片对齐问题，保持原有样式 */
.post-card {
    background-color: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%; /* 确保卡片高度自适应内容但保持一致的基准高度 */
}

/* 控制帖子内容容器 */
.post-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* 统一标题样式 - 限制为一行显示 */
.post-title, .post-card h4 {
    font-size: 1.2rem;
    margin-bottom: 0.8rem;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 统一段落样式 - 限制显示行数 */
.post-excerpt, .post-card p {
    margin-bottom: 1rem;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #666;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* 限制显示3行 */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 4.5em; /* 固定高度，确保对齐 */
}

/* 确保阅读更多链接始终在底部 */
.read-more {
    margin-top: auto; /* 自动填充剩余空间，将链接推到底部 */
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* 确保视频容器和图片大小一致 */
.video-container {
    width: 100%;
    height: 200px;
    border-radius: 4px;
    margin-bottom: 1rem;
    overflow: hidden;
    position: relative;
}

.post-cover {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 1rem;
    display: block;
}

/* 视频元素样式 */
.hover-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 播放图标样式 */
.play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.3s;
}

.play-icon::after {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 15px 0 15px 26px;
    border-color: transparent transparent transparent white;
    margin-left: 6px;
}

/* 统一标题样式 */
.post-title, .post-card h4 {
    font-size: 1.2rem;
    margin-bottom: 0.8rem;
    color: #333;
    word-wrap: break-word; /* 允许长单词或URL等自动换行 */
    overflow-wrap: break-word; /* 更现代的替代属性 */
    word-break: break-word; /* 对于特别长的单词也进行换行 */
    white-space: normal; /* 确保文本正常换行 */
}

/* 统一段落样式 */
.post-excerpt, .post-card p {
    margin-bottom: 1rem;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #666;
    word-wrap: break-word; /* 允许长单词或URL等自动换行 */
    overflow-wrap: break-word; /* 更现代的替代属性 */
    word-break: break-word; /* 对于特别长的单词也进行换行 */
    white-space: normal; /* 确保文本正常换行 */
}

/* 帖子元信息样式 */
.post-meta {
    display: flex;
    gap: 1rem;
    color: #666;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* 统一阅读更多链接样式 */
.read-more, .post-card a:not(.post-title a) {
    color: #4CAF50;
    font-weight: bold;
    display: inline-block;
    margin-top: 0.5rem;
}

.read-more:hover, .post-card a:not(.post-title a):hover {
    text-decoration: underline;
}

/* 热门标记样式 */
.post-grid .post-card:first-child::before {
    content: "热门";
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #ff4757;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    z-index: 10;
}

/* 确保post-content容器不影响对齐 */
.post-content {
    width: 100%;
}

/* 保持Grid布局以实现先横向后纵向排列 */
.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

/* 视频帖子卡片悬停效果 */
.video-container:hover .hover-video {
    transform: scale(1.05);
}

.video-container:hover .play-icon {
    opacity: 0;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .video-container {
        height: 150px;
    }
    
    .post-cover {
        height: 150px;
    }
}

/* 表单样式 */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: #4CAF50;
    outline: none;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

/* 登录/注册页面样式 */
.auth-container, .form-container {
    max-width: 500px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.auth-title, .form-title {
    text-align: center;
    margin-bottom: 2rem;
    color: #333;
}

/* 确保表单提交按钮样式统一 */
.form-button {
    width: 100%;
    padding: 0.8rem;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

.form-button:hover {
    background-color: #45a049;
}

/* 确保容器居中 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* 确保表格样式 */
.users-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.users-table th,
.users-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.users-table th {
    background-color: #f9f9f9;
    font-weight: bold;
    color: #333;
}

.users-table tr:hover {
    background-color: #f5f5f5;
}

/* 添加一些通用工具类 */
.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* 确保所有图标字体可用 */
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css');

/* 错误消息样式 */
.error-message {
    color: #f44336;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

/* 导航栏中的欢迎消息样式 */
nav ul li.welcome-message {
    color: white;
    padding: 0 1rem;
    display: flex;
    align-items: center;
}

nav ul li.welcome-message .logout-link {
    margin-left: 10px;
    color: white;
    text-decoration: underline;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
}

nav ul li.welcome-message .logout-link:hover {
    color: #f0f0f0;
}

/* 确保success-message类有样式（用于显示注销成功等信息） */
.success-message {
    background-color: #d4edda;
    color: #155724;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    text-align: center;
}

/* 页脚样式 */
footer {
    background-color: #333;
    color: #fff;
    padding: 2rem 0;
    margin-top: 3rem;
    position: relative;
    width: 100%;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

footer p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.9;
    text-align: center;
}

/* 添加一些额外的页脚元素样式，以防未来扩展 */
.footer-links {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    color: #fff;
    text-decoration: none;
    font-size: 0.9rem;
    transition: opacity 0.3s ease;
    opacity: 0.8;
}

.footer-links a:hover {
    opacity: 1;
    text-decoration: underline;
}

/* 社交媒体图标样式 */
.social-media {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.social-media a {
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.social-media a:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* 响应式设计 */
@media (max-width: 768px) {
    footer {
        padding: 1.5rem 0;
    }
    
    .footer-container {
        padding: 0 1rem;
    }
    
    footer p {
        font-size: 0.85rem;
    }
    
    .footer-links {
        gap: 1rem;
        margin-bottom: 0.8rem;
    }
    
    .footer-links a {
        font-size: 0.85rem;
    }
}

/* 确保页脚在移动端正确显示 */
@media (max-width: 480px) {
    .footer-links {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }
    
    .social-media {
        gap: 0.8rem;
    }
}

/* 确保所有链接都使用Thymeleaf的th:href属性 */
a {
    color: #4CAF50;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}